<link rel="stylesheet" href="https://file.viplgw.cn/ui/thinku-ielts-new/css/teacher/index.css?v=1.2">

<section id="teacherIndex">
    <p class="headlineTitle"><a href="/">首页</a> &gt; 师资介绍</p>
    <?php $seniority = \Yii::$app->request->get('seniority', 0) ?>
    <div class="headlineCover">
        <div class="headlineLeft">
            <div class="headlineLeftType" style="display: none">
                <div class="teacherLevel">
                    <p>讲师级别：</p>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','全部','讲师级别',''])"
                       href="/teacher.html" <?php echo $seniority == false ? 'class="on"' : '' ?>>全部</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','首席','讲师级别',''])"
                       href="/teacher/1.html" <?php echo $seniority == 1 ? 'class="on"' : '' ?>>首席</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','总监','讲师级别',''])"
                       href="/teacher/2.html" <?php echo $seniority == 2 ? 'class="on"' : '' ?>>总监</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','金牌','讲师级别',''])"
                       href="/teacher/3.html" <?php echo $seniority == 3 ? 'class="on"' : '' ?>>金牌</a>
                </div>
                <div class="teacherLevel">
                    <p>主讲科目：</p>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','全部','主讲科目',''])"
                       href="<?php echo $seniority == 0 ? '/teacher.html' : '/teacher/' . $seniority . '.html' ?>" <?php echo !isset($_GET['subject']) || $_GET['subject'] == false ? 'class="on"' : '' ?>>全部</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','听力','主讲科目',''])"
                       href="<?php echo $seniority == false ? '/teacher.html?subject=听力' : '/teacher/' . $seniority . '.html?subject=听力' ?>" <?php echo isset($_GET['subject']) && $_GET['subject'] == '听力' ? 'class="on"' : '' ?>>听力</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','口语','主讲科目',''])"
                       href="<?php echo $seniority == false ? '/teacher.html?subject=口语' : '/teacher/' . $seniority . '.html?subject=口语' ?>" <?php echo isset($_GET['subject']) && $_GET['subject'] == '口语' ? 'class="on"' : '' ?>>口语</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','阅读','主讲科目',''])"
                       href="<?php echo $seniority == false ? '/teacher.html?subject=阅读' : '/teacher/' . $seniority . '.html?subject=阅读' ?>" <?php echo isset($_GET['subject']) && $_GET['subject'] == '阅读' ? 'class="on"' : '' ?>>阅读</a>
                    <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','写作','主讲科目',''])"
                       href="<?php echo $seniority == false ? '/teacher.html?subject=写作' : '/teacher/' . $seniority . '.html?subject=写作' ?>" <?php echo isset($_GET['subject']) && $_GET['subject'] == '写作' ? 'class="on"' : '' ?>>写作</a>
                </div>
            </div>

            <div class="teacherList">
                <!--遍历infoListItem-->
                <?php foreach ($data as $v) { ?>
                    <div class="infoListItem"
                         onclick="_czc.push(['_trackEvent','师资团队（老师列表）','查看老师','<?php echo $v['name'] ?>',''])">
                        <a href="/teacher-detail/<?php echo $v['id'] ?>.html" class="listItemLeft">
                            <img src="<?php echo $v['pic'] ?>" alt="">
                        </a>
                        <div class="listItemRight">
                            <a href="/teacher-detail/<?php echo $v['id'] ?>.html" class="listItemTitle">
                                <span><?php echo $v['name'] ?></span>
                                <span>讲师级别：<?php if ($v['seniority'] == 1) {
                                        echo '首席讲师';
                                    } elseif ($v['seniority'] == 2) {
                                        echo '总监讲师';
                                    } else {
                                        echo '金牌讲师';

                                    } ?></span>
                                <span>主讲科目：<?php echo $v['subject'] ?></span>
                            </a>
                            <a href="/teacher-detail/<?php echo $v['id'] ?>.html"
                               class="listItemContent"><?php echo $v['smallIntro'] ?></a>
                            <div class="listItemJoin">
                                <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','联系老师','<?php echo $v['name'] ?>',''])"
                                   href="javascript:void(0)" class="ListkownBtn"
                                   @click="contactTeacher('<?php echo $v['name'] ?>')">联系老师</a>
                                <a onclick="_czc.push(['_trackEvent','师资团队（老师列表）','预约试听','<?php echo $v['name'] ?>',''])"
                                   href="javascript:void(0)" class="ListsubBtn"
                                   @click="reserveTeacher('<?php echo $v['name'] ?>')">预约试听</a>
                            </div>
                        </div>
                    </div>
                <?php } ?>

            </div>
            <!-- 分页 -->
            <div class="fenPage">
                <ul>
                    <?php
                    foreach ($pageArray as $k => $v) { ?>
                        <li class="iPage  <?php echo $v == $page ? 'on' : '' ?>"><?php echo $v ?></li>
                    <?php } ?>
                    <?php if (count($pageArray) > 1) { ?>
                        <li class="nextPage">下一页</li>
                    <?php } ?>
                </ul>
            </div>

        </div>


        <div class="headlineRight">
            <div class="experienceCourse">
                <div class="experienceContent">
                    <input type="text" v-model="phone" class="phoneNum" placeholder="请输入您的手机号码">
                    <div class="phoneCodeCover">
                        <input type="text" v-model="code" class="phoneCode" placeholder="验证码">
                        <a href="javascript:void(0)" class="codeBtn" @click="getCode">{{text}}</a>
                    </div>
                    <a href="javascript:void(0)" class="upBtn" @click="submitSure">机经获取</a>
                </div>
            </div>
            <!-- <div class="hotCourseCover">
                <div class="rightTitle">
                    <p>成功案例</p>
                    <a href="/case.html">MORE <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/zx/4@2x.png" alt=""></a>
                </div>
                <?php foreach ($case as $k => $v) {
                if (is_numeric($k)) { ?>
                        <a href="/case-detail/<?php echo $v['id'] ?>.html"
                           class="meansItem">
                            <?php echo $v['name'] ?>
                        </a>
                    <?php }
            } ?>
            </div> -->

            <!-- 干货分享 -->
            <div class="hotCourseCover">
                <div class="rightTitle">
                    <p>干货分享</p>
                    <a href="http://www.thinkuprep.com/news/share.html">MORE <img
                                src="https://file.viplgw.cn/ui/thinku-ielts-new/images/zx/4@2x.png" alt=""></a>
                </div>
                <?php foreach ($recommend as $k => $v) { ?>
                    <a href="/news-information/<?php echo $v['id'] ?>.html" class="leadNewItem">
                        <p class="leadNewImg">
                            <img src="<?php echo $v['pic'] ?>" alt="">
                            <span><?php echo $k + 1 ?></span>
                        </p>
                        <div class="leadNewRight">
                            <p class="newsWords"><?php echo $v['name'] ?></p>
                            <p class="ydNum">
                                <span><?php echo $v['pushTime'] == false ? date('Y-m-d', $v['createTime']) : date('Y-m-d', $v['pushTime']) ?></span><span><?php echo $v['viewCount'] ?>人阅读</span>
                            </p>
                        </div>
                    </a>
                <?php } ?>
            </div>
        </div>
    </div>
    <!-- 预约试听老师弹窗 -->
    <div class="reserveProp" v-cloak v-show="reserve">
        <div class="reserveCenter">
            <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/guide/propcha.png" alt="" class="machineClose"
                 @click="reserve = false">
            <p class="reserveTitle">预约试听</p>
            <input type="text" v-model="reservePhone" class="reserveInputPhone" placeholder="请输入您的手机号">
            <div class="reserveCodeCover">
                <input type="text" v-model="reserveCode" class="reservePhoneCode" placeholder="请输入验证码">
                <a href="javascript:void(0)" class="reserveCodeBtn" @click="reserveGetCode">{{reserveText}}</a>
            </div>
            <a href="javascript:void(0)" class="reserveBtn" @click="reserveSubmitSure">预约试听</a>
        </div>
    </div>
    <!-- 联系老师弹窗 -->
    <div class="contactProp" v-cloak v-show="contact">
        <div class="contactCenter">
            <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/guide/propcha.png" alt="" class="machineClose"
                 @click="contact = false">
            <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/guide/mf1.png" alt="" class="mf1">
            <div class="contactRight">
                <p>联系老师</p>
                <p>扫码添加 {{teacher}} 老师的微信二维码， 与老师一对一交流，助你规划提分方案</p>
                <img src="<?php echo $wx['image']?>" alt="">
            </div>
        </div>
    </div>
    <!-- 获取成功弹窗 -->
    <div class="machineSuccess" v-cloak v-show="successPhone"> <!---->
        <div class="machineCenter">
            <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/guide/xmf.png" alt="" class="xmfLogo">
            <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/guide/propcha.png" alt="" class="machineClose"
                 @click="successPhone = false">
            <p class="wordsText">{{wordsText}}</p>
            <p class="machineCenterWechat"><img
                    src="https://file.viplgw.cn/ui/thinku-ielts-new/images/index_slices/xuezhang.png"></p>
            <p class="wordsText2">{{wordsText2}}</p>
            <a href="javascript:void(0)" class="sure" @click="successPhone = false">确认</a>
        </div>
    </div>
</section>

<script>
    window.teacherIndex = new Vue({
        el: '#teacherIndex',
        data() {
            return {
                phone: '',
                code: '',
                time: 60,
                isSend: false,
                text: '获取验证码',
                successPhone: false,
                wordsText: '领取成功',
                wordsText2: '还差最后一步！添加微信后小助手将发送相关资料给您',
                teacher: '',
                contact: false,
                reservePhone: '',
                reserveCode: '',
                reserveTime: 60,
                reserveIsSend: false,
                reserveText: '获取验证码',
                reserve: false,
            }
        },
        created() {

        },
        mounted() {

        },
        methods: {
            getCode() {
                let that = this;
                let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
                if (that.phone.replace(/\s*/g, "") != '' && myreg.test(that.phone)) {
                    if (!that.isSend) {
                        that.isSend = true;
                        $.post('/cn/api/phone-code', {
                            phone: that.phone
                        }, function (res) {
                            if (res.code == 1) {
                                let timer = setInterval(function () {
                                    that.time--;
                                    if (that.time >= 0) {
                                        that.text = that.time + 's';
                                    } else {
                                        clearInterval(timer);
                                        that.isSend = false;
                                        that.text = '获取验证码';
                                        that.time = 60;
                                    }
                                }, 1000)
                            } else {
                                that.isSend = false;
                                alert(res.message)
                            }
                        }, 'json')

                    }
                } else {
                    alert('手机号码有误');
                }
            },
            submitSure() {
                let that = this;
                let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
                if (that.phone.replace(/\s*/g, "") != '' && myreg.test(that.phone) && that.code.replace(/\s*/g, "") != '') {
                    $.post('/cn/api/leave-words', {
                        phone: that.phone,
                        code: that.code,
                        remark: '机经获取',
                    }, function (res) {
                        if (res.code == 1) {
                            that.successPhone = !that.successPhone;
                            that.wordsText = '领取成功';
                            that.wordsText2 = '稍后会有老师联系您，请保持手机畅通！';
                        } else {
                            alert(res.message)
                        }
                    }, 'json')

                } else {
                    alert('手机号码/验证码有误')
                }

            },
            reserveGetCode() {
                let that = this;
                let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
                if (that.reservePhone.replace(/\s*/g, "") != '' && myreg.test(that.reservePhone)) {
                    if (!that.reserveIsSend) {
                        that.reserveIsSend = true;
                        $.post('/cn/api/phone-code', {
                            phone: that.reservePhone
                        }, function (res) {
                            if (res.code == 1) {
                                let timer = setInterval(function () {
                                    that.reserveTime--;
                                    if (that.reserveTime >= 0) {
                                        that.reserveText = that.reserveTime + 's';
                                    } else {
                                        clearInterval(timer);
                                        that.reserveIsSend = false;
                                        that.reserveText = '获取验证码';
                                        that.reserveTime = 60;
                                    }
                                }, 1000)
                            } else {
                                that.reserveIsSend = false;
                                alert(res.message)
                            }
                        }, 'json')

                    }
                } else {
                    alert('手机号码有误');
                }
            },
            reserveSubmitSure() {
                let that = this;
                let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
                if (that.reservePhone.replace(/\s*/g, "") != '' && myreg.test(that.reservePhone) && that.reserveCode.replace(/\s*/g, "") != '') {
                    $.post('/cn/api/leave-words', {
                        phone: that.reservePhone,
                        code: that.reserveCode,
                        remark: that.teacher + '预约试听',
                    }, function (res) {
                        if (res.code == 1) {
                            that.reserve = false;
                            that.successPhone = !that.successPhone;
                            that.wordsText = '预约成功';
                            that.wordsText2 = '已成功预约' + that.teacher + '老师的试听课程，稍后会有老师和您\n' +
                                '电话联系，并确认相关信息，请您保持电话畅通，谢谢配合！';
                        } else {
                            alert(res.message)
                        }
                    }, 'json')

                } else {
                    alert('手机号码/验证码有误');
                }

            },
            contactTeacher(teacher) {
                this.teacher = teacher;
                this.contact = true;
            },
            reserveTeacher(teacher) {
                this.teacher = teacher;
                this.reserve = true;
            }
        },
    });

    $('.fenPage .iPage').click(function () {
        var url = '/teacher.html';
        var page = $(this).html();
        _czc.push(['_trackEvent', '雅思资深讲师', '下一页', '/teacher.html', ''])
        window.location.href = url + '?page=' + page;
    });
    $('.nextPage').click(function () {
        var url = '/teacher.html';
        var page = parseInt($('.fenPage .iPage.on').html()) + 1;
        if ($('.fenPage .iPage.on').next().html() != '下一页') {
            window.location.href = url + '?page=' + page;
        }
    })
</script>
